package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DzJgmx;
import com.ruoyi.system.service.IDzJgmxService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 结果明细Controller
 * 
 * @author ruoyi
 * @date 2022-09-28
 */
@RestController
@RequestMapping("/system/jgmx")
public class DzJgmxController extends BaseController
{
    @Autowired
    private IDzJgmxService dzJgmxService;

    /**
     * 查询结果明细列表
     */
    @PreAuthorize("@ss.hasPermi('system:jgmx:list')")
    @GetMapping("/list")
    public TableDataInfo list(DzJgmx dzJgmx)
    {
        startPage();
        List<DzJgmx> list = dzJgmxService.selectDzJgmxList(dzJgmx);
        return getDataTable(list);
    }

    /**
     * 导出结果明细列表
     */
    @PreAuthorize("@ss.hasPermi('system:jgmx:export')")
    @Log(title = "结果明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DzJgmx dzJgmx)
    {
        List<DzJgmx> list = dzJgmxService.selectDzJgmxList(dzJgmx);
        ExcelUtil<DzJgmx> util = new ExcelUtil<DzJgmx>(DzJgmx.class);
        util.exportExcel(response, list, "结果明细数据");
    }

    /**
     * 获取结果明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:jgmx:query')")
    @GetMapping(value = "/{mxId}")
    public AjaxResult getInfo(@PathVariable("mxId") Long mxId)
    {
        return AjaxResult.success(dzJgmxService.selectDzJgmxByMxId(mxId));
    }

    /**
     * 新增结果明细
     */
    @PreAuthorize("@ss.hasPermi('system:jgmx:add')")
    @Log(title = "结果明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DzJgmx dzJgmx)
    {
        return toAjax(dzJgmxService.insertDzJgmx(dzJgmx));
    }

    /**
     * 修改结果明细
     */
    @PreAuthorize("@ss.hasPermi('system:jgmx:edit')")
    @Log(title = "结果明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DzJgmx dzJgmx)
    {
        return toAjax(dzJgmxService.updateDzJgmx(dzJgmx));
    }

    /**
     * 删除结果明细
     */
    @PreAuthorize("@ss.hasPermi('system:jgmx:remove')")
    @Log(title = "结果明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{mxIds}")
    public AjaxResult remove(@PathVariable Long[] mxIds)
    {
        return toAjax(dzJgmxService.deleteDzJgmxByMxIds(mxIds));
    }
}
